<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>文件上传</title>

  <script src="./ckeditor.js"></script>
  <script src="./translations/zh-cn.js"></script>
  <script>
    var editor;

    function load(){
      ClassicEditor.create(document.querySelector('#editor'), {
        toolbar: ['bold', 'italic', 'imageUpload', 'link', '|', 'undo', 'redo'],
        language: 'zh-cn',
        ckfinder: {
          uploadUrl: '/file/ckedit/upload'
        }
      }).then(function (e) {
        editor = e;
      }).catch(function (e) {
        console.error(e);
      });
    }

    function getData() {
      var textString = editor.getData();
      console.log(textString);
    }

    function clearData() {
      editor.setData('');
    }
  </script>
</head>
<body onload="load()">
<textarea name="content" id="editor"></textarea>
<div>
  <button onclick="getData()">获取富文本框的数据</button>
  <button onclick="clearData()">清空富文本框的数据</button>
</div>
</body>
</html>